﻿using System;
using System.Data;
using System.Text;

namespace msBsc.WebUi
{
    public partial class wfIndex1 : msBsc.Cls.BPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindControls();
            }
        }

        private void BindControls()
        {
            if (!IsPostBack)
            {
            }
        }
//        public string GetBrandHtml()
//        {
//            System.Text.StringBuilder sbHtml = new System.Text.StringBuilder();

//            System.Data.DataSet dst = null;
//            using (Epm.AppLogic.Framework.CDbAccess oCDbAccess = new Epm.AppLogic.Framework.CDbAccess())
//            {
//                dst = oCDbAccess.QueryBySQL(@"
//	SELECT TOP 24
//	BRAND_ID
//	,BRAND_NME=BRAND_NME+CASE WHEN ISNULL(BRAND_NME_EN,'')<>'' THEN '/'+ISNULL(BRAND_NME_EN,'') ELSE '' END
//	,LOGO_IMG_URL 
//	FROM SHP_GOODS_BRAND
//	WHERE IS_HOT=1 AND HOT_LEVEL<>'' ORDER BY NEWID() ASC ");
//            }

//            foreach (DataRow dr in dst.Tables[0].Rows)
//            {
//                sbHtml.Append(@"<li class=""seckill-item-top""  ""><a href=""/mp_GoodsSearch.htm?b=" + dr["BRAND_ID"].ToString() + @""" class=""seckill-link""> <img width=""100%"" height=""100%"" src=""" + dr["LOGO_IMG_URL"].ToString() + @""" border=""0"" class=""seckill-photo"" /> </a></li>");
//            }
//            return sbHtml.ToString();
//        }

        private void dobtnSaveAsTemplete()
        {
            string strPar1 = this.GetParamHtValue("ID");
            string strHtmlRet = "dsfasdfasdfa";
            this.Alert("asdfasdfsadf");



            //判断该笔订单是否在商户网站中已经做过处理
            //如果没有做过处理，根据订单号（out_trade_no）在商户网站的订单系统中查到该笔订单的详细，并执行商户的业务程序
            //如果有做过处理，不执行商户的业务程序

            System.Transactions.TransactionOptions transactionOption = new System.Transactions.TransactionOptions();
            transactionOption.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted;
            transactionOption.Timeout = new TimeSpan(0, 10, 0);
            using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, transactionOption))
            {
                using (Epm.AppLogic.Framework.CDbAccess oacc = new Epm.AppLogic.Framework.CDbAccess())
                {
                    Epm.AppLogic.Framework.CDbParmCollection parmCollection = new Epm.AppLogic.Framework.CDbParmCollection();
                    parmCollection.Add(new Epm.AppLogic.Framework.CDbParm("strOrderNo", ParameterDirection.Input, Epm.AppLogic.Framework.EDbType.String, 36, "fghfghfh"));

                    DataSet ds = oacc.QueryBySQL("select  dd=@strOrderNo ", parmCollection);

                    using (msBsc.AppLogic.DataAlc.CBizShpOrderForm objShpOrderForm = new AppLogic.DataAlc.CBizShpOrderForm())
                    {
                        DataSet ds2 = objShpOrderForm.SelectById("asdfasdf");
                        if (ds2.Tables[0].Rows.Count > 0)
                        {
                            ds2.Tables[0].Rows[0]["sdfsdfsd"] = "kkkk";

                            ds2.Tables[0].Rows[0].Delete();


                            objShpOrderForm.Update(ds2);



                            using (msBsc.AppLogic.DataAlc.CBizShpOrderFormList objShpOrderFormList = new AppLogic.DataAlc.CBizShpOrderFormList())
                            {
                                DataSet ds3 = objShpOrderFormList.SelectById("chdhdhd");
                                if (ds3.Tables[0].Rows.Count > 0)
                                {
                                    ds3.Tables[0].Rows[0]["sdfsdfsd"] = "kkkk";
                                    DataRow drnew = ds3.Tables[0].NewRow();
                                    drnew["item_id"] = objShpOrderFormList.DataObj.NewID();
                                    drnew[""] = "";
                                    ds3.Tables[0].Rows.Add(drnew);

                                    objShpOrderFormList.Update(ds2);
                                }
                            }
                        }
                    }


                    ts.Complete();
                }




//                string strjson= msBsc.AppLogic.Cfg.HttpTools.GetJsonByTable(ds.Tables[0], "", "ddd1", 1, 20, "");
//                this.ExecJScript(@"
// var _data= " + strjson + @";
//laytpl(_html).render(_data, function (render) {
//    $('#divSvcList').prepend(render);
//});");
//                this.SetContrlValue("txtId", "");
                //this.ExecJScript("$('#ddd').val('" + msBsc.AppLogic.Cfg.HttpTools.stringToJson("sadfasgasgdasdfsd") + "');");
            }


//            this.ExecJScript(@"
//            var _html = $('#svc_list_temp').html();
//            jQuery.loadHtml('/pgajax.axd?GETLOGIN=1').done(function (_rets) { if (_rets) { $(".sn-login-info").html(_rets); } });

//            laytpl(_html).render(SvcListData, function (render) {
//                $("#divSvcList").prepend(render);
//            });");
        }

        public override void DoAction()
        {
            if (this.strAction == "btnSaveAsTemplete")
            {
                dobtnSaveAsTemplete();

                //this.ExecJScript("loadSetBrand('" + this.GetParamHtValue("HOT_LEVEL") + "','" + msBsc.AppLogic.Cfg.HttpTools.stringToJson(LoadBrandListContent(this.GetParamHtValue("HOT_LEVEL"), 4).ToString()) + "');");
            }
        }
    }
}